const result = [
  { 'id': '604f764971f93f3ac8f365c2', 'mobile': '13800000002', 'username': '管理员', 'password': 'e10adc3949ba59abbe56e057f20f883e', 'timeOfEntry': '2018-11-02', 'formOfEmployment': 2, 'workNumber': '9002', 'correctionTime': '2018-11-30', 'departmentName': '总裁办', 'staffPhoto': 'http://q6cu3t6jv.bkt.clouddn.com/1063705989926227968?t=1616204161907' },
  { 'id': '604f764971f93f3ac8f365c3', 'mobile': '13800000003', 'username': '孙财', 'password': 'e10adc3949ba59abbe56e057f20f883e', 'timeOfEntry': '2018-11-04', 'formOfEmployment': 2, 'workNumber': '111', 'correctionTime': '2018-11-20', 'departmentName': '市场部', 'staffPhoto': 'http://q6cu3t6jv.bkt.clouddn.com/1063705989926227968?t=1616204161907' },
  { 'id': '604f764971f93f3ac8f365c4', 'mobile': '13800000004', 'username': '罗晓晓', 'password': 'e10adc3949ba59abbe56e057f20f883e', 'timeOfEntry': '2018-12-02', 'formOfEmployment': 1, 'workNumber': '1111', 'correctionTime': '2018-12-31', 'departmentName': '人事部', 'staffPhoto': 'http://q6cu3t6jv.bkt.clouddn.com/1063705989926227968?t=1616204161907' },
  { 'id': '604f764971f93f3ac8f365c5', 'mobile': '13400000001', 'username': '文吉星', 'password': 'e10adc3949ba59abbe56e057f20f883e', 'timeOfEntry': '2018-01-01', 'formOfEmployment': 1, 'workNumber': '1001', 'correctionTime': '1970-01-01', 'departmentName': '人事部' },
  { 'id': '604f764971f93f3ac8f365c6', 'mobile': '13400000002', 'username': '巴思慧', 'password': 'e10adc3949ba59abbe56e057f20f883e', 'timeOfEntry': '2018-01-01', 'formOfEmployment': 1, 'workNumber': '1002', 'correctionTime': '1970-01-01', 'departmentName': '人事部' }
]

// const hireType = [
//   {
//     id: 1,
//     value: '正式'
//   },
//   {
//     id: 2,
//     value: '非正式'
//   }
// ]
const hireTypeMap = {
  '1': '正式',
  '2': '非正式'
}
function fn(result) {
  result.forEach(obj => {
    if ('formOfEmployment' in obj) {
      obj.formOfEmployment = hireTypeMap[obj.formOfEmployment]
    }
  })
  const headers = {
    'id': '编号',
    'password': '密码',
    'mobile': '手机号',
    'username': '姓名',
    'timeOfEntry': '入职日期',
    'formOfEmployment': '聘用形式', // 1-->正式， 2 --> 非正式
    'correctionTime': '转正日期',
    'workNumber': '工号',
    'departmentName': '部门',
    'staffPhoto': '头像地址'
  }
  const header = Object.keys(result[0]).map(item => {
    return headers[item]
  })
  const data = result.map(obj => {
    return Object.values(obj)
  })
  return { header, data }
}
const { header, data } = fn(result)
console.log(header, data)
